<template>
  <uni-nav-bar title="分拨账户" left-icon="left" @clickLeft="navBack" :fixed="true" statusBar></uni-nav-bar>
  <view class="package direction-start" v-for="item in getList" :key="item.id">
    <view>{{item.name}}</view>
    <view>分拨资金 ￥<text style="font-size: 60rpx;">{{item.money}}</text></view>
    <view class="top but" @click="navTo('fenbo/alteration?id='+item.id)">变动明细</view>
  </view>
</template>


<script setup lang="ts">
  import { showLoading } from '@/utils/prompt';
  import { ref } from 'vue';
  import { navBack, navTo } from '@/utils/navigator';
  import { getFenboList } from '@/gql/fenbo';
  import { toPublish } from '@mqtt';
  import { getDriverID } from '@/stores/driverID';
  const driver_id = getDriverID();
  const getList = ref()
  init()
  function init() {
    showLoading('正在加载');
    const payload = {
      query: getFenboList,
      variables: {
        driver_id
      },
    };
    toPublish('ql/driver/getFenboList', payload, (obj : any) => {
      uni.hideLoading();
      const { data } = obj;
      getList.value = data.getFenboList;
    });
  }
</script>

<style scoped lang="less">
  .top {
    margin-top: 15rpx;
  }

  .but {
    padding: 10rpx 30rpx;
    min-width: 100rpx;
    text-align: center;
    border-radius: 5px;
    background: #1F91FE;
    color: #FFFFFF;
  }
</style>